﻿using LightORM.Core.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Data.SqlClient;

namespace UnitTest
{


    /// <summary>
    ///This is a test class for ParameterCacheTest and is intended
    ///to contain all ParameterCacheTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ParameterCacheTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GetSpParameters
        ///</summary>
        [TestMethod()]
        public void GetSpParametersTest()
        {
            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["UnitTest.Properties.Settings.WebGame3ConnectionString"].ConnectionString; ; // TODO: Initialize to an appropriate value
            string spName = "wg_Castle_Reset"; // TODO: Initialize to an appropriate value
            SqlParameter[] expected = null; // TODO: Initialize to an appropriate value
            SqlParameter[] actual;

            //actual = ParameterCache.GetSpParameterSet(connectionString, spName,true);
            //foreach (var item in actual)
            //{
            //    Console.WriteLine("{0},{1}", item.ParameterName, item.Direction);
            //}
            //actual = ParameterCache.GetSpParameterSet(connectionString, spName, true);
            //actual = ParameterCache.GetSpParameterSet(connectionString, spName, true);
            //actual = ParameterCache.GetSpParameterSet(connectionString, spName, true);
            //actual = ParameterCache.GetSpParameterSet(connectionString, spName, true);


            
            actual = ParameterCache.ResolveSpParameters(connectionString, spName);
            foreach (var item in actual)
            {
                Console.WriteLine("{0},{1}", item.ParameterName, item.Direction);
            }
            actual = ParameterCache.ResolveSpParameters(connectionString, spName);
            actual = ParameterCache.ResolveSpParameters(connectionString, spName);

            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
